package pers.goetboy.sys.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.goetboy.common.AbstractController;
import pers.goetboy.common.EntityState;
import pers.goetboy.common.exception.service.ServiceTipsException;
import pers.goetboy.sys.model.entity.Role;
import pers.goetboy.sys.model.entity.User;
import pers.goetboy.sys.services.UserService;

import java.util.List;

/**
 * @author goetb
 */
@RestController("/user")
public class UserController extends AbstractController<User,UserService> {


    /**
     * 获取用户列表
     */
    @GetMapping("/list")
    public IPage<User> list(Integer current, Integer size) {
        return service.page(new Page(current, size));
    }


    /**
     * 更新用户角色信息
     *
     * @param param 使用{@link UserParam#id} 用户id {@link UserParam#roles}角色信息
     */
    @PutMapping(value = "/updateRole/{id}")
    public void updateUserRole(@PathVariable Long id, @RequestBody List<Role> roles) {
        service.updateUserRole(id, roles);
    }

}
